package store.lunangangster.engine.impl.service;

import store.lunangangster.engine.ProcessEngineConfiguration;
import store.lunangangster.engine.impl.cmd.Command;
import store.lunangangster.engine.impl.cmd.CompleteTaskCmd;
import store.lunangangster.engine.impl.interceptor.CommandContext;
import store.lunangangster.engine.impl.query.TaskQuery;
import store.lunangangster.engine.impl.query.TaskQueryImpl;
import store.lunangangster.engine.service.TaskService;

public class TaskServiceImpl extends ServiceImpl implements TaskService {

  public TaskServiceImpl(
      ProcessEngineConfiguration processEngineConfiguration) {
    super(processEngineConfiguration);
  }

  @Override
  public void complete(String taskId) {
    executor.execute(new CompleteTaskCmd(taskId));
  }

  @Override
  public TaskQuery createTaskQuery() {
    return executor.execute(new Command<TaskQuery>() {
      @Override
      public TaskQuery execute(CommandContext commandContext) {
        return new TaskQueryImpl(executor);
      }
    });
  }
}
